#include "capinterface.h"
#include "application.h"
#include <utility>
#include <vector>
#include <map>

#define MYCAP_STRING_LEN	1024

enum MYCAP_CONNECTION{
	MYCAP_CON_HTTPS=1,
	MYCAP_CON_BYPASS=2,
	MYCAP_CON_CLIENTBLOCK=4,
	MYCAP_CON_BLOCK=8,
	MYCAP_CON_OK=16
};


struct MyCapRequest{
	char*  url; 
	short requeston;
	int connvalues;
	short acceptgzip;
};
struct MyCapConnection{
	MyCapRequest request;
	//char val1[MYCAP_STRING_LEN];
};

typedef std::vector<std::pair<const char*, int> > mycaplist;

typedef std::map<const char, char*> mycapmapurl;

typedef std::map<const char, mycaplist*> mycapmap;


class MyCAP: public CAPInterface{
private:

	short findinlist(mycaplist*, const char*);

	mycapmap mymap;
	mycapmapurl myurlmap;
	mycapmapurl myhostmap;
	mycaplist urls;
	mycaplist hosts;
	char* header;
	char* headerignoretag;

	char*ipfile; 
	char*blockpage;
	char*blockpagehost;
	
public:
	CAP_RETURN ConnectCAP(void**, const char*, char**, int*);
	CAP_RETURN RequestCAP(void**, char**, unsigned int *, HeaderHandlerInterface* );
	CAP_RETURN PreRequestCAP(void**, HeaderHandlerInterface* );
	CAP_RETURN ResponseCAP(void**, char**, unsigned int*, HeaderHandlerInterface*);
	CAP_RETURN PreResponseCAP(void**, HeaderHandlerInterface* );
	void CloseCAP(void**);
	CAP_RETURN	InitCAP();
	CAP_RETURN	ClearCAP();
};
